//用于显示添加角色表单的窗体
var addRoleWin = Ext.create('Ext.window.Window', {
	title: '添加角色',
	height: 400,
	width: 600,
	layout: 'fit',
	items: [addRoleForm],
	closeAction: 'hide', // 防止窗体被销毁
	listeners: {
		close: function(panel, eOpts) {
			addRoleForm.reset();
			addRoleForm.down('grid').setSelection();
		}
	}

});



//用于显示角色可以添加的权限列表的窗体
var roleAddAuthWin = Ext.create('Ext.window.Window', {
	title: '可添加权限',
	height: 400,
	width: 600,
	layout: 'fit',
	items: [roleAddAuthGird],
	closeAction: 'hide', // 防止窗体被销毁
	listeners: [{
		close: function(panel, eOpts) {
			roleAddAuthGird.setSelection();//点击关闭按钮时将选项清空
		}
	}],
	buttons: [{
		text: '确认',
		itemId: 'roleAddAuthWinButton',
		listeners: [{
			click: function() {
				var roleId = role_gird.getSelectionModel().getSelected().items[0].data.id;
				var selectArray = roleAddAuthGird.getSelectionModel().getSelected(); //得到被选择的行的数组.
				var jsonArray = new Array();
				Ext.each(selectArray.items, function(result) {
					jsonArray.push(result.data.id);
				});
				var json = Ext.JSON.encode(jsonArray);
				Ext.Ajax.request({
					url: zuulUrl+'/'+authServiceName+'/admin/role',
					async: true, //ASYNC 是否异步( TRUE 异步 , FALSE 同步)
					method: 'put',
					params: {
						roleId: roleId,
						newUrlJson: json
					},
					success: function(response, opts) {
						Ext.Msg.alert("Success", "添加成功");
						Ext.data.StoreManager.lookup('roleAuthStore').reload();
						roleAddAuthWin.close();
					},
					failure: function(response, opts) {
						Ext.Msg.alert("Error", "该功能暂时不可用！");
					}
				});
			}
		}]

	}]
});

//用于显示添加用户和编辑用户的窗体
var userWin = Ext.create('Ext.window.Window', {
	//title: '编辑用户',
	height: 400,
	width: 600,
	layout: 'fit',
	items: [userTabPanel],
	closeAction: 'hide', // 防止窗体被销毁
	listeners: {
		close: function(panel, eOpts) {
			//editorUserForm.reset();
			//editorUserForm.down('grid').setSelection();
		}
	},
	buttons: [{
		text: '确认',
		itemId: 'userWinButton',
		listeners: [{
			click: function() {
				if(userList.isCreate==1)//如果是创建用户
					createUser();
				else//如果是更新用户
					updateUser();
			}
		}]
	}]
});